
<script type="text/html" data-template-name="html">
    <div class="form-row">
        <label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="common.label.property"></span></label>
        <input type="text" id="node-input-property" style="width:70%">
    </div>
    <div class="form-row">
        <label for="node-input-tag"><i class="fa fa-filter"></i> <span data-i18n="html.label.select"></span></label>
        <input type="text" id="node-input-tag" placeholder="h1">
    </div>
    <div class="form-row">
        <label for="node-input-ret"><i class="fa fa-sign-out"></i> <span data-i18n="html.label.output"></span></label>
        <select id="node-input-ret" style="width:70%">
            <option value="html" data-i18n="html.output.html"></option>
            <option value="text" data-i18n="html.output.text"></option>
            <option value="attr" data-i18n="html.output.attr"></option>
            <option value="compl" data-i18n="html.output.compl"></option>
            <!-- <option value="val">return the value from a form element</option> -->
        </select>
    </div>
    <div class="form-row">
        <label for="node-input-as">&nbsp;</label>
        <select id="node-input-as" style="width:70%">
            <option value="single" data-i18n="html.format.single"></option>
            <option value="multi" data-i18n="html.format.multi"></option>
        </select>
    </div>
    <div class="form-row">
        <label for="node-input-outproperty">&nbsp;</label>
        <span data-i18n="html.label.in" style="padding-left:8px; padding-right:2px; vertical-align:-1px;"></span> <input type="text" id="node-input-outproperty" style="width:64%">
    </div>
    <div id='html-prefix-row' class="form-row" style="display: none;">
        <label for="node-input-chr" style="width: 230px;"><i class="fa fa-tag"></i> <span data-i18n="html.label.prefix"></span></label>
        <input type="text" id="node-input-chr" style="text-align:center; width: 40px;" placeholder="_">
    </div>
    <br/>
    <div class="form-row">
        <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
        <input type="text" id="node-input-name" style="width:70%" data-i18n="[placeholder]common.label.name">
    </div>
</script>

<script type="text/javascript">
    RED.nodes.registerType('html',{
        category: 'parser',
        color:"#DEBD5C",
        defaults: {
            name: {value:""},
            property: {value:"payload", validate: RED.validators.typedInput({ type: 'msg', allowUndefined: true }) },
            outproperty: {value:"payload", validate: RED.validators.typedInput({ type: 'msg', allowUndefined: true }) },
            tag: {value:""},
            ret: {value:"html"},
            as: {value:"single"},
            chr: { value: "_" }
        },
        inputs:1,
        outputs:1,
        icon: "parser-html.svg",
        label: function() {
            return this.name||this.tag||"html";
        },
        labelStyle: function() {
            return this.name?"node_label_italic":"";
        },
        oneditprepare: function() {
            $("#node-input-property").typedInput({default:'msg',types:['msg']});
            $("#node-input-outproperty").typedInput({default:'msg',types:['msg']});
            $('#node-input-ret').on( 'change', () => {
                if ( $('#node-input-ret').val() == "compl" ) {
                    $('#html-prefix-row').show()
                } else {
                    $('#html-prefix-row').hide()
                }
            });
        }
    });
</script>
